<?php
session_start();

if(isset($_SESSION['alb_id'])) {
// tao ra file chua cac anh trong album => chi khi thuc hien upload moi sinh thu muc album
$filealbum = $_SESSION['alb_id']+1;
mkdir("./uploads/".$filealbum."/", 0777);
$uploaddir = "./uploads/".$filealbum."/"; 

$file = $uploaddir . basename($_FILES['uploadfile']['name']); 
$size=$_FILES['uploadfile']['size'];
// lay ra tat ca thong tin cac anh thuoc album dang chon?
$_SESSION['uploadfile'] = basename($_FILES['uploadfile']['name']);
$_SESSION['size'] = $size;
if($size>1048576)
{
	echo "error file size > 1 MB";
	unlink($_FILES['uploadfile']['tmp_name']);
	exit;
}
if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $file)) { 
  echo "success"; 
} else {
	echo "error ".$_FILES['uploadfile']['error']." --- ".$_FILES['uploadfile']['tmp_name']." %%% ".$file."($size)";
}
}
?>